﻿namespace WebMarkupMin.Example.Mvc
{
	using System.Web.Optimization;

	using BundleTransformer.Core.Bundles;
	using BundleTransformer.Core.Orderers;

	public class BundleConfig
	{
		public static void RegisterBundles(BundleCollection bundles)
		{
			bundles.UseCdn = true;

			var nullOrderer = new NullOrderer();

			var commonStylesBundle = new CustomStyleBundle("~/Bundles/CommonStyles");
			commonStylesBundle.Include("~/Content/fonts/fonts.css",
				"~/Content/all.less");
			commonStylesBundle.Orderer = nullOrderer;

			bundles.Add(commonStylesBundle);

			var modernizrBundle = new CustomScriptBundle("~/Bundles/Modernizr");
			modernizrBundle.Include("~/Scripts/modernizr-2.*");
			modernizrBundle.Orderer = nullOrderer;

			bundles.Add(modernizrBundle);

			var jQueryBundle = new CustomScriptBundle("~/Bundles/Jquery",
				"http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.1.min.js");
			jQueryBundle.Include("~/Scripts/jquery-{version}.js");
			jQueryBundle.Orderer = nullOrderer;
			jQueryBundle.CdnFallbackExpression = "window.jquery";

			bundles.Add(jQueryBundle);

			var commonScriptsBundle = new CustomScriptBundle("~/Bundles/CommonScripts");
			commonScriptsBundle.Include("~/Scripts/bootstrap/dropdown.js",
				"~/Scripts/webmarkupmin/common.js");
			commonScriptsBundle.Orderer = nullOrderer;

			bundles.Add(commonScriptsBundle);

			var minificationFormScriptsBundle = new CustomScriptBundle("~/Bundles/MinificationFormScripts");
			minificationFormScriptsBundle.Include("~/Scripts/jquery.validate.js",
				"~/Scripts/jquery.validate.unobtrusive.js",
				"~/Scripts/bootstrap/button.js",
				"~/Scripts/webmarkupmin/minification-form.js");
			minificationFormScriptsBundle.Orderer = nullOrderer;

			bundles.Add(minificationFormScriptsBundle);
		}
	}
}